package com.heima.article.listener;

import com.alibaba.fastjson.JSON;
import com.heima.article.service.ApArticleService;
import com.heima.model.mess.UpdateArticleMess;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: xrl
 * @Date: 2022/10/23  11:31
 * @Version 1.0
 * 用户阅读行为
 */
@Component
@Slf4j
public class BehaviorListener {

    @Autowired
    private ApArticleService apArticleService;

    /**
     * 阅读
     */
//    @KafkaListener(topics = HotArticleConstants.HOT_ARTICLE_SCORE_TOPIC)
    public void onMessage(String msg) {
        if (StringUtils.isNotBlank(msg)) {
            //转换为java对象
            UpdateArticleMess articleMess = JSON.parseObject(msg, UpdateArticleMess.class);
            apArticleService.updateBehavior(articleMess);
        }
    }
















}
